package Servlet;

import Bean.Blog;
import MySql.MySqlTool;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Vector;

/**
 * Created by liushiyin on 17-11-17.
 */
public class GetBlog extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        response.setCharacterEncoding("UTF-8");
        request.setCharacterEncoding("UTF-8");

        MySqlTool mySqlTool=new MySqlTool();
        Vector<Blog> lists=mySqlTool.queryBlogs("select * from blog");
        mySqlTool.close();
        request.setAttribute("bloglist",lists);
        request.getRequestDispatcher("MyBlog.jsp").forward(request,response);
    }
}
